import re
import os

def walk(dir_name, log_file):
    for name in os.listdir(dir_name):
        path = os.path.join(dir_name, name)
        if os.path.isfile(path):
            read_ee_log(path, log_file)
        else:
            walk(path, log_file)

def read_ee_log(old_file, new_file):
    print 'Analyze: ', old_file
    """test all dialects against URL"""
    w = False
    logfile = open(new_file, "w")
    with open(old_file) as infile:
        for line in infile:
            if 'SendSwiftMessage.java' in line:
                w = True
            # print w0
            if w:
                print line
                logfile.write(line)
                if '[End]' in line:
                    w = False
                
    logfile.write(" - END -")
    logfile.close()

if __name__ == "__main__":
    walk("/tmp/eelog", "/tmp/ee.log")
